const App = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		items: [{
				value: '1',
				name: '1星'
			},
			{
				value: '2',
				name: '2星'
			},
			{
				value: '3',
				name: '3星'
			},
			{
				value: '4',
				name: '4星'
			},
			{
				value: '5',
				name: '5星',
				checked: 'true'
			}
		],
		stars: 5,
		order_id: 0,
		order_ids: 0,
		page_list: {},
		is_fw: false,
		is_done: 0,
		is_text: '确定完成!',
		appointment_type: 0,
	},
	QxFuwu: function() {
		this.setData({
			is_fw: false,
			//order_ids: 0
		})
	},
	QxPing: function() {
		this.setData({
			is_done: 0
		})
	},
QdWc: function(e) {
		var order_id = e.currentTarget.id
		this.setData({
			is_fw: true,
			order_ids: order_id
		})
	},
	radioChange(e) {
		console.log('radio发生change事件，携带value值为：', e.detail.value)
		this.setData({
			stars: e.detail.value
		})
		const items = this.data.items
		for (let i = 0, len = items.length; i < len; ++i) {
			items[i].checked = items[i].value === e.detail.value
		}
		this.setData({
			items
		})
	},
	pingjia: function(e) {
		this.setData({
			ping: e.detail.value
		})
	},
	SubmitFuwu: function() {
		let _this = this;
		var order_id = this.data.order_ids
		App._post_form('appointment/confirm_finish', {
			order_id: order_id
		}, function(result) {
			console.log(result)
			if (result.msg == 'success') {
				wx.navigateTo({
					url: './comment/comment?order_id=' + _this.data.order_ids,
				})
			}
		});
		
		// App._post_form('appointment/confirm_finish', {
		// 	order_id: order_id
		// }, function(result) {
		// 	console.log(result)
		// 	if (result.msg == 'success') {
		// 		_this.setData({
		// 			is_fw: false,
		// 			is_done: 1,
		// 			//order_ids: 0
		// 		})
		// 		//wx.navigateBack();
		// 	}
		// });
	},
	SubmitPing: function() {
		let _this = this;
		wx.navigateTo({
			url: './comment/comment?order_id=' + _this.data.order_ids,
		})
	},
	// SubmitPing: function () {
	//   let _this = this;
	//   console.log(_this.data.stars)
	//   console.log(_this.data.ping)
	//   console.log(_this.data.order_ids)
	//   App._post_form('appointment/ping_finish', {
	//     stars: _this.data.stars,
	//     ping: _this.data.ping,
	//     order_id: _this.data.order_ids
	//   }, function (result) {
	//     if (result.msg = 'success') {
	//       wx.navigateBack();
	//     }
	//   });
	// },
	Queding: function(e) {
		var order_id = e.currentTarget.id
		console.log(order_id)
		this.setData({
			is_fw: true,
			order_ids: order_id
		})
	},
	getOrder: function() {
		let _this = this;
		var order_id = this.data.order_id
		App._post_form('appointment/log', {
			order_id: order_id
		}, function(result) {
			if (result.msg = 'success') {
				console.log(result)
				var page_list = result.data
				var appointment_type = page_list.appointment_type
				_this.setData({
					page_list: page_list.list,
					appointment_type: appointment_type
				})
			}
		});
	},
	onLoad: function(options) {
		var order_id = options.order_id
		this.setData({
			order_id: order_id,
		})
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {
		this.getOrder()
	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {

	}
})
